package com.devshephard.framework.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * 应用程序上下文保持者
 * @author zarehome
 *
 */
@Component
public class ContextHolder {
	
	
	private static ConfigurableApplicationContext applicationContext;
	
	
	private static Environment environment;
	
	
	@Autowired
	public void init(ConfigurableApplicationContext applicationContext) {
		ContextHolder.applicationContext = applicationContext;
		environment = applicationContext.getEnvironment();
	}

	/**
	 * 获取应用程序上下文
	 * @return
	 */
	public static ConfigurableApplicationContext getApplicationContext() {
		return applicationContext;
	}

	/**
	 * 获取应用程序环境对象
	 * @return
	 */
	public static Environment getEnvironment() {
		return environment;
	}

	
	
	
}
